package com.mlnx.work.config;

import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.mlnx.work.properties.WorkProperties;

import org.shan.spring.druid.EnableDruid;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * Created by amanda.shan on 2019/9/24.
 */
@Configuration
@EnableDruid
@EnableConfigurationProperties(WorkProperties.class)
public class WorkConfig {

    public static void main(String[] args) {
        System.out.println(IdWorker.getId());
        System.out.println(IdWorker.getTimeId());
        System.out.println("202005202243011641263118032339845122".length());
    }

    @ConditionalOnMissingBean
    @Bean
    public PasswordEncoder encoder(){
        return new PasswordEncoder() {
            @Override
            public String encode(CharSequence rawPassword) {
                return rawPassword.toString();
            }

            @Override
            public boolean matches(CharSequence rawPassword, String encodedPassword) {
                return rawPassword.equals(encodedPassword);
            }
        };
    }
}
